package com.leetcode.LC;

import java.util.Arrays;

public class LC1051 {
    public int heightChecker(int[] heights) {

        int[] ints = new int[heights.length];
        for (int i = 0; i < heights.length; i++) {
            ints[i] = heights[i];
        }

        Arrays.sort(heights);
        int count = 0;
        for (int i = 0; i < heights.length; i++) {
            if (ints[i] != heights[i]) {
                count++;
            }
        }
        return count;
    }

    public static void main(String[] args) {
        System.out.println(new LC1051().heightChecker(new int[]{5, 1, 2, 3, 4}));
    }
}
